#!/usr/bin/env python
#coding=utf-8
"""
run: python manage.py test ft --settings=contacts.settings.local_d7s3

Creating test database for alias 'default'...
Creating test database for alias 'sql001'...
http://localhost:8081
.
----------------------------------------------------------------------
Ran 1 test in 14.932s

OK
Destroying test database for alias 'default'...
Destroying test database for alias 'sql001'...
"""

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

from django.test import LiveServerTestCase
import time

class AdminTest(LiveServerTestCase):
    fixtures = ['auth.json']

    def setUp(self):
        self.browser = webdriver.Firefox()

    def tearDown(self):
        self.browser.quit()

    def test_admin_site(self):
        # print self.live_server_url
        # http://localhost:8081
        self.browser.get(self.live_server_url + '/admin/')
        body = self.browser.find_element_by_tag_name('body')
        #self.assertIn('Django administration', body.text)
        self.assertIn(u'Django 管理', body.text)
        username_field = self.browser.find_element_by_name('username')
        username_field.send_keys('admin')
        password_field = self.browser.find_element_by_name('password')
        password_field.send_keys('admin')
        password_field.send_keys(Keys.RETURN)
        time.sleep(3)
        body = self.browser.find_element_by_tag_name('body')
        ## self.assertIn('Site administration', body.text)
        ###username or password is error
        ## self.assertIn('Please enter the correct username and password', body.text)
        time.sleep(3)


